--[[
描述 ： 数据操作 类
作者 ： 付大志
修改 ： jwg- qt
时间 ： 14/12/01
]]


MLData=Class(MLPlugin,'MLData');   
MLData.mInstance=nil;
MLData.mData = nil;

function MLData.arrayToStr(array) 
    local arryStr = ''; 
    local num = #array;
   	for i,v in ipairs(array) do
   		arryStr = arryStr..v
   		if i ~= num then 
   			arryStr = arryStr..','
   		end
   	end
   	return arryStr;
end

function MLData.strToArray(str) 
   local data={};
    string.gsub(str, '[^,]+', function(w) 
        data[#data + 1] = tonumber(w);
     end)
    return data;
end

function MLData.print(array) 
   --local data=MLData.arrayToStr(array);
   print(data);
end


function MLData.shortToByteArray(number) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	local strarray = staticInst:shortToByteArrayLua(number);
	local data =  MLData.strToArray(strarray);
	return data;]]
end

function MLData.intToByteArray(number) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	local strarray = staticInst:intToByteArrayLua(number);
	local data =  MLData.strToArray(strarray);
	return data;]]
end

function MLData.byteToInt(byteArray) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	local arraystr = MLData.arrayToStr(byteArray);
	local number =  staticInst:byteToIntLua(strarray);
	return number;]]
end

function MLData.byteToShort(byteArray) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	local arraystr = MLData.arrayToStr(byteArray);
	local number =  staticInst:byteToShortLua(strarray);
	return number;]]
end

function MLData.andExt(a,b) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	return  staticInst:andExt(a,b);]]
end

function MLData.orExt(a,b) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	return  staticInst:orExt(a,b);]]
end


function MLData.BitLMove(a,b) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	return  staticInst:BitLMove(a,num);]]
end

function MLData.BitRMove(a,b) 
	--[[local  staticInst =  MLPlugin.getStaticPluginInst('com.MLink.plugins.MLData.MLData');
	return  staticInst:BitRMove(a,num);]]
end


function MLData:initData(array) 
    --[[local dataStr = self.arrayToStr(array);
    print('MLData:initData',dataStr)
    self.mInstance = self:getPlugInst('com.MLink.plugins.MLData.MLData',dataStr)
    return self; ]]
end


function MLData:getData() 
    --[[local dataStr = self.mInstance:getByteLua();
    local data= self.strToArray(dataStr);
    return data; ]]
end
function MLData:findByte(array) 
    --[[local dataStr = self.arrayToStr(array);
    local  result = self.mInstance:findByteLua(dataStr);
    if result > 0 then result = result + 1 end
    return result;]]
end



function MLData:getByteInRange(pos,len) 
	 --[[ if pos > 0 then pos = pos -1; end
    local dataStr = self.mInstance:getByteInRangeLua(pos,len);
    local data= self.strToArray(dataStr);
    return data; ]]
end

function MLData:appendByte(array) 
   --[[ local dataStr = self.arrayToStr(array);
    self.mInstance:appendByteLua(dataStr);]]
end

function MLData:replaceByteInRange(array, pos,  len) 
    --[[if pos > 0 then pos = pos -1; end
    local dataStr = self.arrayToStr(array);
     self.mInstance:replaceByteInRangeLua(dataStr, pos, len);]]
end

function MLData:deassemble(src, des) 
   --[[ local srcStr = self.arrayToStr(src);
    local desStr = self.arrayToStr(des);
     self.mInstance:deassembleLua(srcStr, desStr);]]
end


function MLData:initDataWithInst(instance) 
    --[[self.mInstance =  instance;  
    return self; ]]
end